package com.dc.controller;

import com.dc.annotation.Log;
import com.dc.common.ResponseResultVO;
import com.dc.model.SysOperLog;
import com.dc.ro.SysOperLogRO;
import com.dc.service.SysOperLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 操作日志记录
 */
@Api(tags = "日志管理")
@RestController
@RequestMapping("/operLog")
public class SysOperlogController {

    @Resource
    private SysOperLogService operLogService;

    @PostMapping("/list")
    @ApiOperation(value = "分页查询日志列表", notes = "分页查询日志列表")
    public ResponseResultVO list(@RequestBody SysOperLogRO operLog) {
        return operLogService.selectOperLogList(operLog);
    }

    @Log(title = "操作日志", businessDesc = "删除日志")
    @GetMapping("/deleteId")
    @ApiOperation(value = "删除日志", notes = "删除日志")
    public ResponseResultVO remove(String ids) {
        return operLogService.deleteOperLogByIds(ids);
    }

    @Log(title = "操作日志", businessDesc = "清空日志")
    @GetMapping("/clean")
    @ApiOperation(value = "清空日志", notes = "清空日志")
    public ResponseResultVO clean() {
        return operLogService.cleanOperLog();
    }

    @PostMapping("/add")
    public ResponseResultVO add(@RequestBody SysOperLog operLog) {
        return operLogService.insertOperLog(operLog);
    }
}
